/* 
 * Copyright 2005-2008 Samuel Mello & Eduardo Schnell
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; version 2 or later of the License.
 * 
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 * 
 */

/*
 * ImageDisplay.java
 *
 * Created on 13 July 2006, 19:55
 */

package datasoul.util;

import java.awt.Graphics;
import java.awt.Graphics2D;

import datasoul.templates.ImageTemplateItem;

/**
 *
 * @author  samuelm
 */
public class ImageDisplay extends javax.swing.JPanel {

    /**
	 * 
	 */
	private static final long serialVersionUID = 2533776947932846677L;
	private ImageTemplateItem imageTemplateItem;
    
    /** Creates new form ImageDisplay */
    public ImageDisplay() {
        initComponents();
        imageTemplateItem = new ImageTemplateItem();
    }

    public ImageTemplateItem getImageTemplateItem() {
        return imageTemplateItem;
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                formComponentResized(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 86, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 71, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
        updateSize();
    }//GEN-LAST:event_formComponentResized
    
    @Override
    public void paint(Graphics g){
        super.paint(g);
        imageTemplateItem.draw((Graphics2D)g, 1.0f);
    }
    
    public void updateSize(){
        imageTemplateItem.setWidth( this.getWidth() );
        imageTemplateItem.setHeight( this.getHeight() );
        this.repaint();
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    
}

